﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XMLSpreadGear.Core;

namespace XMLSpreadGear.Headers
{
    public class Workbook:BaseElement
    {
        private DocumentProperties dpDocumentProperties;

        public DocumentProperties DocumentProperties
        {
            get { return dpDocumentProperties; }
            set { dpDocumentProperties = value; }
        }
        private ExcelWorkbook ewExcelWorkbook;

        public ExcelWorkbook ExcelWorkbook
        {
            get { return ewExcelWorkbook; }
            set { ewExcelWorkbook = value; }
        }
        private Styles sStyles;

        public Styles Styles
        {
            get { return sStyles; }
            set { sStyles = value; }
        }

        private Worksheet wsWorksheet;

        public Worksheet Worksheet
        {
            get { return wsWorksheet; }
            set { wsWorksheet = value; }
        }

        public Workbook(string strlocalname)
            : base(strlocalname)
        {
        }

        public Workbook(string strlocalname, DocumentProperties documentProperties, ExcelWorkbook excelWorkbook, Styles styles,Worksheet worksheet)
            : this(strlocalname)
        {
            this.dpDocumentProperties = documentProperties;
            this.ewExcelWorkbook = excelWorkbook;
            this.sStyles = styles;
            this.wsWorksheet = worksheet;
        }

        internal protected override IDictionary<string, string> RegisterElements()
        {
            IDictionary<string, string> dic = new Dictionary<string, string>();
            if(this.DocumentProperties!= null)
                dic.Add("DocumentProperties", this.DocumentProperties.ToString());

            if(this.ExcelWorkbook !=null)
                dic.Add("ExcelWorkbook", this.ExcelWorkbook.ToString());

            if(this.Styles != null)
                dic.Add("Styles", this.Styles.ToString());

            if(this.Worksheet != null)
                dic.Add("Worksheet", this.Worksheet.ToString());

            return dic;
        }

        internal protected override IDictionary<string, string> RegisterAttributes()
        {
            IDictionary<string, string> dic = new Dictionary<string, string>();
            dic.Add("xmlns", "urn:schemas-microsoft-com:office:spreadsheet");
            dic.Add("xmlns:o", "urn:schemas-microsoft-com:office:office");
            dic.Add("xmlns:x", "urn:schemas-microsoft-com:office:excel");
            dic.Add("xmlns:dt", "uuid:C2F41010-65B3-11d1-A29F-00AA00C14882");
            dic.Add("xmlns:ss", "urn:schemas-microsoft-com:office:spreadsheet");
            dic.Add("xmlns:html", "http://www.w3.org/TR/REC-html40");
            return dic;
        }

        protected override void SetDefaults()
        {
            return;
        }
    }
}
